package com.thinking.project.monitorserver.service;

import com.thinking.project.monitorserver.mapper.WorkerMapper;
import com.thinking.project.monitorserver.pojo.Worker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description 功能描述：
 * @Author tangsixiang@163.com
 * @DATE 2019/6/21 11:22
 * @Version 1.0
 **/

@Service
public class WorkerService {

    @Autowired
    StringRedisTemplate template;

    @Autowired
    WorkerMapper mapper;

    public Worker selectByPrimaryKey(Integer workerId) {
        return mapper.selectByPrimaryKey(workerId);
    }

    public int deleteByPrimaryKey(Integer workerId) {
        return mapper.deleteByPrimaryKey(workerId);
    }

    public int insert(Worker record) {
        return mapper.insert(record);
    }

    public int insertSelective(Worker record) {
        return mapper.insertSelective(record);
    }

    public int updateByPrimaryKey(Worker record) {
        return mapper.updateByPrimaryKey(record);
    }

    public int updateByPrimaryKeySelective(Worker record) {
        return mapper.updateByPrimaryKeySelective(record);
    }

    public List<Worker> selectForListPage(String workerName,Object startPage, Object pageSize) {
        return mapper.selectForListPage(workerName,startPage, pageSize);

    }
    public List<Worker> selectForListPageNoPassword(String workerName,Object startPage, Object pageSize) {
        return mapper.selectForListPageNoPassword(workerName,startPage, pageSize);

    }

    public int selectForListNum(String workerName) {
        return mapper.selectForListNum(workerName);
    }

    public Worker selectByUserName(Worker record) {
        return mapper.selectByUserName(record);
    }


    public  boolean checkToken(String  workerId){
        System.out.println("获取token 验证是否存在数据");
      return  template.hasKey(String.format("user:login:mark:[%s]", workerId));
    }


}
